package com.mytransaction.Util;

import com.mytransaction.myAnnotation.MyAnt;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import java.lang.reflect.Method;
@SuppressWarnings("all")
public class myUtils {
    public static MyAnt getextTransaction(ProceedingJoinPoint proceedingJoinPoint) throws NoSuchMethodException {
        String methodName = proceedingJoinPoint.getSignature().getName();
        // 获取目标对象
        Class<?> classTarget = proceedingJoinPoint.getTarget().getClass();
        // 获取目标对象类型
        Class<?>[] par = ((MethodSignature) proceedingJoinPoint.getSignature()).getParameterTypes();
        // 获取目标对象方法
        Method objMethod = classTarget.getMethod(methodName, par);
        MyAnt myAnt = objMethod.getDeclaredAnnotation(MyAnt.class);
        return myAnt;
    }
}
